package errmsg

const (
	SUCCESS = 200
	ERROR   = 500

	// ERROR_USERNAME_USED code=1000... 用户模块的错误
	ERROR_USERNAME_USED      = 1001
	ERROR_PASSWORD_WRONG     = 1002
	ERROR_USER_NOT_EXIST     = 1003
	ERROR_TOKEN_EXIST        = 1004
	ERROR_TOKEN_RUNTIME      = 1005
	ERROR_TOKEN_WRONG        = 1006
	ERROR_TOKEN_TYPE_WRONG   = 1007
	ERROR_PASSWORD_EXIST     = 1008
	ERROR_SRC_PASSWORD_WRONG = 1009
	//code=2000... 分类模块的错误
	ERROR_CATENAME_USED = 2001
	//code=3000... 文章模块的错误
	ERROR_ARTICLE_NOT_EXIST = 3001
)

var codemsg = map[int]string{
	SUCCESS:                 "OK",
	ERROR:                   "FAIL",
	ERROR_USERNAME_USED:     "用户名已存在！",
	ERROR_PASSWORD_WRONG:    "密码错误！",
	ERROR_USER_NOT_EXIST:    "用户未注册！",
	ERROR_TOKEN_EXIST:       "TOKEN错误！",
	ERROR_TOKEN_RUNTIME:     "TOKEN已过期！",
	ERROR_TOKEN_WRONG:       "TOKEN不正确！",
	ERROR_TOKEN_TYPE_WRONG:  "TOKEN格式错误！",
	ERROR_CATENAME_USED:     "分类名称已存在！",
	ERROR_ARTICLE_NOT_EXIST: "文章不存在！",
	ERROR_SRC_PASSWORD_WRONG: "原密码错误！",
	ERROR_PASSWORD_EXIST:     "新密码不能与原密码相同！",
}

func GetErrMsg(code int) string {
	return codemsg[code]
}
